package nz.ac.massey.doi_information_extractor.main;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;

import javax.swing.JFileChooser;

@SuppressWarnings("serial")
public class DefaultNameFileChooser extends JFileChooser implements PropertyChangeListener{

	private String defaultName;
	boolean updatable;
	public DefaultNameFileChooser(String defaultName){
		super();
		this.defaultName = defaultName;
		this.addPropertyChangeListener(JFileChooser.DIRECTORY_CHANGED_PROPERTY,this);
		this.updatable = false;
	}
	@Override
	public void propertyChange(PropertyChangeEvent arg0) {
		setSelectedFile(new File(defaultName));
		updateUI();
	}

	public void setDefaultName(String defaultName){
		this.defaultName = defaultName;
		setSelectedFile(new File(defaultName));
	}
}
